package com.wanglin.myapplication.slice;

import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.DependentLayout;
import ohos.agp.components.Text;
import ohos.agp.components.element.ShapeElement;
import ohos.agp.utils.Color;

public class SecondAbilitySlice extends AbilitySlice {
    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        DependentLayout layout=new DependentLayout(this);

        layout.setWidth(DependentLayout.LayoutConfig.MATCH_PARENT);
        layout.setHeight(DependentLayout.LayoutConfig.MATCH_PARENT);

        ShapeElement element=new ShapeElement();
        element.setRgbColor(new RgbColor(255,255,255));
        layout.setBackground(element);

        Text text=new Text(this);
        text.setText("开始鸿蒙开发");
        text.setWidth(DependentLayout.LayoutConfig.MATCH_PARENT);
        text.setTextSize(50, Text.TextSizeType.FP);
        text.setTextColor(Color.BLACK);

        DependentLayout.LayoutConfig textLayoutConfig= new DependentLayout.LayoutConfig(DependentLayout.LayoutConfig.MATCH_CONTENT, DependentLayout.LayoutConfig.MATCH_CONTENT);
        textLayoutConfig.addRule(DependentLayout.LayoutConfig.CENTER_IN_PARENT);
        text.setLayoutConfig(textLayoutConfig);
        layout.addComponent(text);
        super.setUIContent(layout);


    }
}
